package com.mes.cloud.util;


import com.mes.cloud.common.auth.UserInfo;
import com.mes.cloud.common.auth.UserInfoContext;

/**
 * Created by faliny on 2017/8/25.
 */


public class UserUtil {

    /**
     * 获取系统登录用户工号 + 姓名
     *
     * @return
     */
    public static String getEmployeeNoAndName(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String employeeNoAndName = "";
        if(userInfo != null){
            employeeNoAndName = userInfo.getEmployeeNo()+userInfo.getRealName();
        }
        return employeeNoAndName;
    }

    /**
     * 获取系统登录用户工号
     *
     * @return
     */
    public static String getEmployeeNo(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String employeeNo = "";
        if(userInfo != null){
            employeeNo = userInfo.getEmployeeNo();
        }
        return employeeNo;
    }

    /**
     * 获取系统登录用户姓名
     *
     * @return
     */
    public static String getName(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String name = "";
        if(userInfo != null){
            name = userInfo.getRealName();
        }
        return name;
    }

    /**
     * 获取系统登录用户ID
     *
     * @return
     */
    public static String getEmployeeId(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String employeeId = null;
        if(userInfo != null){
            employeeId = userInfo.getEmployeeId();
        }
        return employeeId;
    }

    /**
     * 创建人工号
     *
     * @return
     */
    public static String getCreateByNo(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String employeeNo = "";
        if(userInfo != null){
            employeeNo = userInfo.getEmployeeNo();
        }
        return employeeNo;
    }

    /**
     * 创建人姓名
     *
     * @return
     */
    public static String getCreateByName(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String name = "";
        if(userInfo != null){
            name = userInfo.getRealName();
        }
        return name;
    }
    /**
     * 修改人工号
     *
     * @return
     */
    public static String getUpdateByNo(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String employeeNo = "";
        if(userInfo != null){
            employeeNo = userInfo.getEmployeeNo();
        }
        return employeeNo;
    }

    /**
     * 修改人姓名
     *
     * @return
     */
    public static String getUpdateByName(){
        UserInfo userInfo = UserInfoContext.getUserInfo();
        String name = "";
        if(userInfo != null){
            name = userInfo.getRealName();
        }
        return name;
    }

    /**
     * 获取用户信息
     * @return
     */
    public static UserInfo getUserInfo(){
        return UserInfoContext.getUserInfo();
    }

}
